package com.imay.live.adapter;

import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.imay.live.R;
import com.imay.live.helper.HotLabelCallBack;
import com.imay.live.model.HotLabelModel;

import java.util.List;

/**
 * Created by liangzhenxiong on 2017/4/6 0006.
 * 发现-分类-栏目
 */

public class AllHotLabelLinearAdapter extends BaseQuickAdapter<Object, BaseViewHolder> {

    HotLabelCallBack hotLabelCallBack;


    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public AllHotLabelLinearAdapter(List<Object> data, HotLabelCallBack hotLabelCallBack) {
        super(R.layout.item_hotlabel, data);
        this.hotLabelCallBack = hotLabelCallBack;
    }


    @Override
    protected void convert(final BaseViewHolder helper, Object item) {
        if (item instanceof HotLabelModel) {
            final HotLabelModel hotLabelModel = (HotLabelModel) item;
            TextView textView = helper.getView(R.id.tv_content);
            textView.setText(helper.getConvertView().getContext().getString(R.string.label_tag_format,hotLabelModel.getLabel()));
            if (helper.getConvertView().getResources().getString(R.string.str_allhot).equals(hotLabelModel.getLabel())) {
                textView.setTextSize(17);
                textView.setTextColor(helper.getConvertView().getResources().getColor(R.color.color_ff));
            } else {
                textView.setTextSize(14);
                textView.setTextColor(helper.getConvertView().getResources().getColor(R.color.text_ff50));
            }
            helper.convertView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    hotLabelCallBack.onClickTitle(hotLabelModel.getLabel());
                }
            });
        }

    }
}
